<? 
	$title="Delete category"; 
	$pageid="5";
	$accessid="a00";
	
	require("required/dbconnect.php"); 
	require("required/function.php");

	if(isset($_POST['btnsubmit']))
	{
		$id=de_id($_POST['id']);
		$delete=mysql_query("delete from os_category where id=$id")or die(mysql_error());
		header("Location:cat_management.php?action=2");
	}
	else
	{
		require("required/header.php");
		$enid=$_GET['id'];
		
		$id=de_id($enid);
		$check_sub=mysql_query("select count(*) as result from os_sub_category where main_category=$id");
		
		if(mysql_result($check_sub,0,"result")>0)
		{
			
?>
<table width="95%" cellpadding="2" cellspacing="1">
	
	<td valign="top" align="center">
	<table width="100%" class="solidborder" >
	<tr>
		<td><font color="#FF0000">This category contains sub category, delete failed.</font></td>
	</tr>
	<tr>
		<td colspan="3" align="center">
		<input type="button" value="Back" onClick="history.go(-1)" class="button">
		</td>
	</tr>
	</table>
	</td>
 
</table>
<?	
		}else{
	
?>
<table width="95%" cellpadding="2" cellspacing="1">
	
	<td valign="top" align="center">
	<table width="100%" >
	<tr>
		<td class="title">Confirm to delete the record?</td>
	</tr>
	<tr>
		<td colspan="3" align="center">
		<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
		<input type="hidden" value="<?= $enid ?>" name="id">
		<input type="submit" value="Yes" name='btnsubmit' class="button">
		<input type="button" value="No" onClick="history.go(-1)" class="button">
		</form>
		</td>
	</tr>
	</table>
	</td>
 
</table>
<? } }require("required/footer.php"); ?>
